﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;

[CustomEditor(typeof(UIButtonGroup))]
public class UIButtonGroupInspector : Editor
{

    private void OnInspectorUpdate()
    {

    }

    public override void OnInspectorGUI()
    {
        //var target = (UIButtonGroup)(serializedObject.targetObject);
        serializedObject.Update();


        var OnButtonDown = serializedObject.FindProperty("OnButtonDown");
        var OnButtonDownIndex = serializedObject.FindProperty("OnButtonDownIndex");
        var lastSelectIndex = serializedObject.FindProperty("lastSelectIndex");
        var lastSelectName = serializedObject.FindProperty("lastSelectName");
        var modeProp = serializedObject.FindProperty("mode");

        using (var changeCheck = new EditorGUI.ChangeCheckScope())
        {
            EditorGUILayout.PropertyField(modeProp);


            if ((UIButtonGroup.Mode)modeProp.enumValueIndex == UIButtonGroup.Mode.Name)
            {
                EditorGUILayout.PropertyField(OnButtonDown);
                EditorGUILayout.PropertyField(lastSelectName);
            }
            else
            {
                EditorGUILayout.PropertyField(OnButtonDownIndex);
                EditorGUILayout.PropertyField(lastSelectIndex);
            }



            if (changeCheck.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }

        }



    }
}